package com.elong.android.specialhouse.notification;

import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.support.v4.app.NotificationCompat;

/**
 * @ClassName: BasicNotificationBuild
 * @Description: 默认的 NotificationBuilder
 * @author kaiqi.li
 * @date 2015年1月5日 下午3:50:52
 */
public class BasicNotificationBuilder implements NotificationInterface {

    private Context mContext ;
    private GetPendingIntent mCallback ;

    public BasicNotificationBuilder(Context context , GetPendingIntent callback){
        mContext = context ;
        mCallback = callback ;
    }

    /**
     * 创建一个默认的NotificationBuilder
     * 设置3个必填参数.setSmallIcon(iconId)
     *           .setContentTitle(title)
     *           .setContentText(content)
     */
    @Override
    public NotificationCompat.Builder generateNotifacationBuilder(String title, String content, int iconId) {
        NotificationCompat.Builder builder =
                new NotificationCompat.Builder(mContext)
                        .setSmallIcon(iconId)
                        .setContentTitle(title)
                        .setContentText(content)
                        .setAutoCancel(true)
                        .setDefaults(Notification.DEFAULT_ALL) ;
        if (mCallback == null) {
            return builder ;
        }
        return builder.setContentIntent(mCallback.getPendingIntent()) ;
    }
    /**
     *
     * @ClassName: GetPendingIntent
     * @Description: 回调接口，获取具体的PendingIntent以解决用户点击back键时返回到哪个界面的问题
     *               根据不同的需求可以在getPendingIntent函数的实现中设置不同的PendingIntent
     * @author kaiqi.li
     * @date 2015年1月5日 下午5:38:59
     */
    public interface GetPendingIntent{
        public PendingIntent getPendingIntent() ;
    }
}
